<?php
class SetEnvironmentController extends BaseController
{
	/**
	 * 接收页面上数据传入到service
	 * @Author   Leikes
	 * @DateTime 2016-01-08T10:22:30+0800
	 */
	public function setEnvironment()
	{
		$host     =Input::get('host');
		$dbName   =Input::get('dbName');
		$dbUname  =Input::get('dbUname');
		$dbPword  =Input::get('dbPword');
		$dbPrefix =Input::get('dbPrefix');
		$username =Input::get('username');
		$password =Input::get('password');

		$dbConfig =new DbConfigService();
		$dbConfig->setHost($host);
		$dbConfig->setDbName($dbName);
		$dbConfig->setDbUname($dbUname);
		$dbConfig->setDbPword($dbPword);
		$dbConfig->setDbPrefix($dbPrefix);
		$dbConfig->setUserName($username);
		$dbConfig->setPassWord($password);

		$errCode  =$dbConfig->checkConfig();
		if(!$errCode['errCode']==0){
			return Response::json($errCode);
		}
		else{
			$dbConfig->writeConfig();
			return Response::json($errCode);
		}

	}
	public function showView(){
		return View::make('install.guidance');
	}
}
?>